<template>
  <iframe v-if="byteluckLoginUrl" :src="byteluckLoginUrl" frameborder="0" style="display: none;"></iframe>
</template>
<script lang="ts" setup>
  import { ref } from 'vue';
import { getToken } from '/@/utils/auth';
  import { defHttp } from '/@/utils/http/axios';

  const byteluckLoginUrl = ref('')
  const login = async () => {
    // if(process.env.VITE_NO_AUTH_BYTELUCK === 'true'){
    //   return
    // }
    const token = getToken();
    if (token) {
      let url = await defHttp.get({
        url: '/sys/baiteda/login',
        headers: {
          authorization: token,
          'x-access-token': token,
        },
      });
      if(url){
        url = url.replace(/^http(s?):\/\//, '')
        const urlList = url.split('/')
        urlList.splice(0, 1)
        url = urlList.join('/')
        byteluckLoginUrl.value = '/' + url + '&state=/emptypath'
      }
    }
  };

  login()
</script>
